amends "../snippetTest.pkl"

local str1 = "How"
local str2 = "you"
local str3 = "this"

examples {
  ["equality"] {
    "abc" == "abc"
    "abc" == "abd"
  }

  ["inequality"] {
    "abc" != "abc"
    "abc" != "abd"
  }

  ["interpolation"] {
    "\(str1) are \(str2) today? Are \(str2) hungry?"
    "Can \(str2 + " nest \(str3)") for me?"
    "Is \(str1 + str2) a word?"
    "Is \("soma") a word?"
    "Can \(str2 + " nest (((") for me?"
    "Can \(str2 + " nest )))") for me?"
    "Can you \( new Dynamic { x = "nest \( new Dynamic { y = str3 }.y )" }.x ) for me?"
  }

  ["interpolation of different types"] {
    "\(42)"
    "\(1.23)"
    "\("Pigeon")"
    "\(false)"
    "\(1.23.ns)"
    "\(1.23.mb)"
    "\(Pair(1, 2))"
    "\(List(1, 2, 3))"
    "\(Set(1, 2, 3))"
    "\(Map(1, 2, 3, 4))"
    "\(new Listing { 1 2 3 })"
    "\(new Mapping { ["Pigeon"] = 42; ["Barn Owl"] = 21 })"
    "\(new Dynamic { name = "Pigeon"; age = 42 })"
    "\(new Person { name = "Pigeon"; age = 42 })"
    "\(new Person2 { name = "Pigeon"; age = 42 })"
    "\(null)"
    "\(Null(new Person { name = "Pigeon"; age = 42 }))"
  }

  ["escaping"] {
    "\\\"\\("
    "\t\r\n"
    "\u{9}\u{30}\u{100}\u{1000}\u{10000}\u{010000}\u{0010000}\u{00010000}"
  }

  ["subscript"] {
    str3[2]
    module.catch(() -> str3[-1])
    module.catch(() -> str3[4])
  }

  ["dollar sign has no special meaning"] {
    "123$"
    "$123"
    "$&%"
    "$"
  }
}

local class Person { name: String; age: Int }

local class Person2 {
  name: String
  age: Int
  function toString() = "My name is \(name) and I'm \(age) years old."
}
